#include<iostream>

using namespace std;

#include<stdlib.h>
#include<string.h>

class Date
{
public:
	Date(int year = 0, int month = 0, int day = 0)
	{
		_year = year;
		_month = month;
		_day = day;
	}

	void Print()
	{
		cout << _year << "-" << _month << "-" << _day << endl;
	}

	bool operator<(const Date& d)
	{
		if (_year < d._year)
			return true;
		if ((_year = d._year) && (_month < d._month))
			return true;
		if ((_year = d._year) && (_month = d._month) && (_day < d._day))
			return true;
		return false;
	}

	Date& operator=(const Date& d)
	{
		if (this != &d)
		{
			_year = d._year;
			_month = d._month;
			_day = d._day;
		}
		return *this;
	}

	~Date()
	{
		_year = 0;
		_month = 0;
		_day = 0;
	}

private:
	int _year;
	int _month;
	int _day;
};

typedef int DataType;

class Stack
{
public:
	Stack(DataType* a, int n)
	{
		_array = (int*)malloc(sizeof(int) * n);
		if (_array == NULL)
		{
			perror("malloc fail");
			return;
		}
		memcpy(_array, a, sizeof(int) * n);
		_top = n;
		_capacity = n;
	}

	Stack(int StackCapacity = 4)
	{
		_array = (int*)malloc(sizeof(int) * StackCapacity);
		if (_array == NULL)
		{
			perror("malloc fail");
			return;
		}
		_top = 0;
		_capacity = StackCapacity;
	}

	void Push(DataType x)
	{
		CheckCapacity();
		_array[_top++] = x;

	}

	Stack(const Stack& s)
	{
		_array = (int*)malloc(sizeof(s._array));
		if (_array == NULL)
		{
			perror("malloc fail");
			return;
		}

		memcpy(_array, s._array, sizeof(int) * (s._capacity));
		_top = s._top;
		_capacity = s._capacity;
	}


	Stack& operator=(const Stack& s)
	{
		if (this != &s)
		{
			memcpy(s._array, _array, sizeof(int) * _capacity);
			_top = s._top;
			_capacity = s._capacity;
		}

		return *this;
	}

	~Stack()
	{
		if (_array)
		{
			free(_array);
			_array = nullptr;
			_top = 0;
			_capacity = 0;
		}
	}


private:
	void CheckCapacity()
	{
		if (_top == _capacity)
		{
			int newcapacity = _capacity * 2;
			DataType* temp = (DataType*)realloc(_array, newcapacity * sizeof(DataType));
			if (temp == NULL)
			{
				perror("realloc??!!!");
				return;
			}
			_array = temp;
			_capacity = newcapacity;
		}
	}
private:
	DataType* _array;
	int _top;
	int _capacity;
};



int main()
{
	Date d1(2025, 5, 17);
	Date d2(2023, 5, 17);

	//cout << (d1 < d2) << endl;


	int i, j, k;
	i = j = k = 0;

	Date d3, d4, d5;
	d3 = d4 = d5 = d1;

	Stack s4(8);
	s4.Push(1);
	s4.Push(2);
	s4.Push(3);
	s4.Push(4);
	s4.Push(5);
	s4.Push(6);

	Stack s1, s2, s3;
	s1 = s2 = s3 = s4;


	int a[10] = { 1,2,3,4,5,6,7,8,9,10 };
	int b[10] = { 0 };


	return 0;
}